package cn.pisoft.axis;

import java.rmi.RemoteException;

import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;


public class CallObject {
	public static void main(String[] args) {
		try {
			//String url = "http://soa.yepg.com:9734/SCMIS/GIS/xlcxdw";
			String url = "http://soa.yepg.com:9734/EIP/GDInfo_GDRK";
			Service service = new Service();
			Call call = (Call) service.createCall();
			call.setTargetEndpointAddress(url);
			call.setOperationName(new QName(url, "exec"));
			 call.addParameter(new QName("http://www.tbi.ydtf.com/",
			 "orgid"),XMLType.SOAP_STRING,ParameterMode.IN);
			// call.addParameter(new QName("http://www.tbi.ydtf.com/",
			// "yhbh"),XMLType.SOAP_STRING,ParameterMode.IN);
			 call.setReturnType(new QName("http://www.tbi.ydtf.com/",
			"response"), Gdrk.class);

			// 注册映射关系
			QName GdrkInfo = new QName("http://www.tbi.ydtf.com/", "Xljg");
			call.registerTypeMapping(Gdrk.class, GdrkInfo,
					new BeanSerializerFactory(Gdrk.class, GdrkInfo),
					new BeanDeserializerFactory(Gdrk.class, GdrkInfo));

			Gdrk gdrk = (Gdrk) call.invoke(new Object[] {"昆明"});
			System.out.println(gdrk.getPowersupplypopulace());
		} catch (ServiceException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
